package com.sx.pipeline.adapter

import android.annotation.SuppressLint
import android.text.TextUtils
import android.util.Log
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.noober.background.view.BLTextView
import com.sx.pipeline.R
import com.sx.pipeline.arouth.RouteManager
import com.sx.pipeline.repos.http.res.MessageListVo
import com.sx.pipeline.repos.http.res.ReleaseSupplyVo
import com.sx.pipeline.utils.AndroidUtil
import com.sx.pipeline.utils.CountDownUtil

/**
 * @Author：YY
 * @Date：2022/2/10
 * @Describe: 参与供应列表适配器
 */
class ProvideListAdapter
    (
    dataList: MutableList<ReleaseSupplyVo>
) : BaseQuickAdapter<ReleaseSupplyVo, BaseViewHolder>(
    R.layout.item_provide_info, dataList
) {
    private var countDownUtil: CountDownUtil? = null

    override fun convert(holder: BaseViewHolder, item: ReleaseSupplyVo) {
        holder.setText(R.id.tv_finish_time, item.createTime)
        //标题
        holder.setText(R.id.tv_title, item.title)
        //供应时间
        holder.setText(R.id.tv_provide_time, "供应时间：${item.startTime}-${item.endTime}")
        //供应服务区域
        holder.setText(R.id.tv_provide_area, "供应服务区域：${item.addressDetail}")
        //供应负责人
        holder.setText(R.id.tv_provide_principal, "供应负责人：${item.contact}")
        if (item.status==1){
            //未询价前隐藏手机号
            //联系方式
            holder.setText(R.id.tv_provide_contact, "联系方式：**** **** ****")
        }else{
            //联系方式
            holder.setText(R.id.tv_provide_contact, "联系方式：${item.contactPhone}")
        }

        if (item.inquiryPrice.toInt()==0){
            holder.setGone(R.id.tv_provide_money,true)
        }else{
            holder.setVisible(R.id.tv_provide_money,true)
            //价格
            holder.setText(R.id.tv_provide_money,""+item.inquiryPrice)
        }

        //咨询
        holder.getView<BLTextView>(R.id.tv_consult).setOnClickListener {
            RouteManager.Mine.intentToProvideDetail(item.id)
        }

    }

}